﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Itegracion.Framework.Forms;

namespace Itegracion.Browser
{
    public partial class fmLogin : fmBase
    {
        public fmLogin()
        {
            InitializeComponent();
        }

        public DataTable User;
        public Element Message;
        private void buEntrar_Click(object sender, EventArgs e)
        {
            User = new DataTable(); 
            Message = new Element();
            _("Itegracion.Framework", "User", "Traer", tbUsuario, tbContrasena)
                .Out(Message, User);
            if (string.IsNullOrEmpty(Message.Value+""))
                DialogResult = DialogResult.OK;
            else
                ep.SetError(buEntrar, Message.Value+"");
        }

        private void fmLogin_Load(object sender, EventArgs e)
        {
            tbUsuario.Focus();
        }

        private void fmLogin_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter) {
                buEntrar_Click(sender, e);
            }
            if (e.KeyCode == Keys.Escape)
            {
                Application.Exit();
            }
        }        
    }
}
